﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using IBatisNet.DataMapper;

namespace WS
{
    using WS.Domain;
    /// <summary>
    /// Summary description for WS_Vaitro
    /// </summary>
    [WebService(Namespace = "WS")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class WS_Vaitro : System.Web.Services.WebService
    {
        ISqlMapper sqlMapper;
        List<Vaitro> list;

        public WS_Vaitro()
        {
            sqlMapper = Mapper.Instance();
        }

        #region Web Method Vai trò Base

        [WebMethod]
        public List<Vaitro> ReadList()
        {
            list = (List<Vaitro>)sqlMapper.QueryForList<Vaitro>("getVaitro", null);
            return list;
        }

        [WebMethod]
        public bool InsertVaitro(Vaitro Vaitro)
        {
            try
            {
                sqlMapper.Insert("insertVaitro", Vaitro);
                return true;
            }
            catch (Exception) { return false; }
        }

        [WebMethod]
        public bool UpdateVaitro(Vaitro Vaitro)
        {
            try
            {
                sqlMapper.Update("updateVaitro", Vaitro);
                return true;
            }
            catch (Exception) { return false; }
        }

        [WebMethod]
        public bool DeleteVaitro(int id)
        {
            try
            {
                sqlMapper.Delete("deleteVaitro", id);
                return true;
            }
            catch (Exception) { return false; }
        }

        #endregion
    }
}
